package org.keeners.imageviewer {	
	
	import flash.events.EventDispatcher;
	import flash.events.Event;
	import flash.events.TimerEvent;
	import flash.events.MouseEvent;
	import flash.events.KeyboardEvent;
	
	import flash.display.MovieClip;
	import flash.display.Sprite;
	import flash.display.Stage;
	
	import flash.filters.DropShadowFilter;   
	
	import org.keeners.imageviewer.ImageViewerBase;
	
	public class Controller extends EventDispatcher{
				
		private var _stage:Stage;
		private var _config:Config;
		private var _background:MovieClip;
		
		public var params:Object;
		public var imageviewer:ImageViewerBase;
		
		public function Controller(stage, config:Config, p){			
			/*
				initializes the imageviewer, params, and attaches resize event
			*/
			
			params = p;
						
			_background = new mc_background()
			_config = config;
			_config.load_arguments(p);
			
			_stage = stage;
			_stage.addChild(_background);			
			_stage.addEventListener(Event.RESIZE, stretch_background_to_stage);
						
			stretch_background_to_stage();
									
	   }		
		
		public function initialize_image_callback():void{			
			/*
				called after imageviewer is initialized, nothing to do - 
				currently just a placeholder.
			*/
			
		}
		
		public function initialize_image():void{			
			/*
				creates the viewer and adds it to the stage
			*/
			
			imageviewer = new ImageViewerBase(_config, _stage, initialize_image_callback)
			_stage.addChild(imageviewer);
		}
		
		public function stretch_background_to_stage(e = undefined):void{			
		   /*
				stretches background gradient on init and resize
		   */
		   
		   _background.width = _stage.stageWidth;
		   _background.height = _stage.stageHeight;
		}
		
		
		
		
	}
}
